<template>
  <div class="form-layout">
    <!--左侧导航-->
    <div class="nav-left">
      <customAnchor
        :itemList="[
          { name: 'box-base', title: '基础信息' },
        ]"
      />
    </div>
    <!--表单区域-->
    <div class="form-right" ref="formRight">
      <customForm :data="form" :rules="propRules" ref="editForm" :disabled="propReadonly">
        <template #content>
          <div id="box-base" class="box-title">基础信息</div>
          <customFormItem label="值" name="value" :parent="_self" :form="form" />
          <customFormItem label="标签" name="label" :parent="_self" :form="form" />
          <customFormItem label="排序" name="sort" :parent="_self" :form="form" :type="constCommon.formItemType.inputNumber.name" />
          <customFormItem label="禁用" name="flagDisabled" :parent="_self" :form="form" :type="constCommon.formItemType.switch.name" />
          <div class="label-class">
            <strong>颜色</strong> <t-color-picker class="label-picker" v-model="form.color" />
          </div>
        </template>
      </customForm>
    </div>
  </div>
</template>

<script>
import customAnchor from '@/components/custom/form/customAnchor.vue'

export default {
  data() {
    return {
      form: {},
      viewData: {},
    }
  },
  created() {
    let that = this
    this.$emit('event-register', {
      validate: (callback) => {
        return this.$refs.editForm.validate(callback)
      },
      beforeSave: () => {
        this.$emit('data-callback', this.form)
        return true
      },
      afterMove: (formData, initData) => {
        this.form = global.utils.jsonClone(formData)
        this.$set(this.form, 'dictTypeId', this.propInitData.id)
        this.$set(this.form, 'dictTypeCode', this.propInitData.code)
        if (this.strings.isBlank(this.form.color)) {
          this.$set(this.form, 'color', '#000000')
          this.$set(this.form, 'flagDisabled', false)
        }
      },
      afterSave: () => {},
      beforeDelete: () => {
        return true
      },
      afterDelete: () => {},
      beforeFlow: (flowButtonKey) => {
        return true
      },
      afterFlow: (flowButtonKey) => {},
      beforeClose: () => {
        return true
      },
      afterClick() {},
    })
  },
  props: {
    propParent: Object,
    propInitData: Object,
    propPrimaryKey: String,
    propDictionaries: Object,
    propCurrentRow: Object,
    propViewFormData: Object,
    propReadonly: Boolean,
    propStatus: String,
    propRules: Object
  },
  components: { customAnchor },
  computed: {},
  methods: {
  },
}
</script>

<style lang="scss" scoped>
  .label-picker {
    display: inline-block;
    vertical-align: middle;
  }
</style>
